package com.service;


import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.BoostingQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;


public interface SearchService {

    /**
     * term查询
     * @param index 库
     * @param field 要查询什么列
     * @param value 查询的值
     * @throws Exception
     */
    void termQuery(String index, String field, String value) throws Exception;

    void termsQuery(String index, String field, String... values) throws Exception;

    /**
     * 查询所有数据
     * @param index
     * @throws Exception
     */
    void matchAll(String index) throws Exception;

    void matchQuery(String index, String field, String value) throws Exception;

    void matchQueryWithOperator(String index, String field, String value, Operator operator) throws Exception;

    /**
     * 多列的查询
     * @param index
     * @param value
     * @param filed
     * @throws Exception
     */
    void multiMatch(String index, String value, String... filed) throws Exception;

    /**
     * 根据多个id查询
     * @param index
     * @param ids
     * @throws Exception
     */
    void idsQuery(String index, String... ids) throws Exception;

    /**
     * 前缀查询
     * @param index
     * @param filed
     * @param value
     * @throws Exception
     */
    void prefixQuery(String index, String filed, String value) throws Exception;

    void FuzzyQuery(String index, String filed, String value, int prefixLength) throws Exception;

    void wildcardQuery(String index, String filed, String value) throws Exception;

    void rangeQuery(String index, String filed) throws Exception;

    void regexpQuery(String index, String filed, String reg) throws Exception;

    void createScroll(String index, QueryBuilder queryBuilder, int size, String time) throws Exception;

    /**
     * 因为scrollid是在有index的时候创建的,所以后面就不需要传递index了
     * @param scrollId
     * @param time
     * @throws Exception
     */
    void scrollQuery(String scrollId, String time) throws Exception;

    /**
     * 根据条件删除数据
     * @param index
     * @param queryBuilder
     * @throws Exception
     */
    void deleteByQuery(String index, QueryBuilder queryBuilder) throws Exception;

    void booleanQuery(String index, BoolQueryBuilder boolQueryBuilder) throws Exception;

    void boostingQuery(String index, BoostingQueryBuilder boostingQueryBuilder) throws Exception;

    void highLightQuery(String index, QueryBuilder queryBuilder, HighlightBuilder highlightBuilder) throws Exception;
}
